package presentation;

import javax.swing.JFrame;

import vo.OrderVO;

public class OrderModel {
	
	private OrderFrame orderFrame;
	
	public OrderModel(JFrame frame, OrderVO orderVO) {
		orderFrame = new OrderFrame(orderVO);
		orderFrame.setLocationRelativeTo(frame);
		orderFrame.setVisible(true);
	}
	
	public OrderVO getUserVO() {
		while (true) {
			try {
				Thread.sleep(100);
			} catch (Exception e) {
				e.printStackTrace();
			}
			
			DialogEvent event = orderFrame.getEvent();
			if (event == null) {
				continue;
			}
			if (event == DialogEvent.CANCEL) {
				return null;
			}
			if (event == DialogEvent.CONFIRM) {
				return orderFrame.getOrderVO();
			}
		}
	}

	public void disposeFrame() {
		orderFrame.dispose();
	}

}
